﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Bas;

namespace nERP.Model.Bas
{
    /// <summary>
    /// 单据编码分配
    /// </summary>
	[Table("CodingList")]
    [SoftKey(nameof(CodingList.Code))]
    [Display(Name = "_Model.CodingList")]
    public class CodingList : BasePoco,IPersistPoco, ITenant
    {
        [Display(Name = "_Model._CodingList._Code")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("编码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string Code { get; set; }
        [Display(Name = "_Model._CodingList._CurrentNumber")]
        [Comment("当前流水号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? CurrentNumber { get; set; }
        [Display(Name = "_Model._CodingList._Example")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("当前编码")]
        public string Example { get; set; }
        [Display(Name = "_Model._CodingRule._CodingList")]
        [InverseProperty("CodingList")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Bas.CodingRule.CodingListId))]
        public List<CodingRule> CodingRule_CodingList { get; set; }
        [Display(Name = "_Model._CodingList._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

    }

}
